#include "iuWindows.h"


using namespace Pure;


iuWindows::iuWindows( void )
{
    mHwnd = 0;
    mHinstance = 0;
    mWndProc = 0;
    memset( mTitle, 0, sizeof( mTitle ) );
    mPos.x = mPos.y = 0;
    mSize.x = mSize.y = 0;
}


iuWindows::~iuWindows( void )
{
    Clear();
}


bool iuWindows::Initialize( void )
{
    WNDCLASS WndClass;
 
    WndClass.cbClsExtra = 0;
    WndClass.cbWndExtra = 0;
    WndClass.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
    WndClass.hCursor = LoadCursor( 0, IDC_ARROW );
    WndClass.hIcon = LoadIcon( 0, IDI_APPLICATION );
    WndClass.hInstance = GetHinstance();
    WndClass.lpfnWndProc = mWndProc;
    WndClass.lpszClassName = GetTitle();
    WndClass.lpszMenuName = 0;
    WndClass.style = CS_HREDRAW | CS_VREDRAW;

    RegisterClass( &WndClass );
 

    SetHwnd( CreateWindow( GetTitle(), GetTitle(), WS_OVERLAPPEDWINDOW, GetPos().x, GetPos().y, GetSize().x, GetSize().y, 0, (HMENU)0, GetHinstance(), 0 ) );

    ShowWindow( GetHwnd(), 1 );


    return true;
}

/*
void iuWindows::destroyWindows( void )
{
    DestroyWindow( GetHwnd() );
}
*/


void iuWindows::Clear( void )
{
    UnregisterClass( GetTitle(), GetModuleHandle( 0 ) );
}
